<!DOCTYPE html>
<html lang="en">
<head>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height">
  <meta charset="UTF-8">
  <meta name="Author" content="haley">
  <meta name="Keywords" content="前端最常用的UI插件">
  <meta name="Description" content="最常用的UI插件">
  <script crossorigin="anonymous" integrity="sha384-6ePHh72Rl3hKio4HiJ841psfsRJveeS+aLoaEf3BWfS+gTF0XdAqku2ka8VddikM" src="https://lib.baomitu.com/jquery/1.11.3/jquery.min.js"></script>
  <link crossorigin="anonymous" integrity="sha384-pdapHxIh7EYuwy6K7iE41uXVxGCXY0sAjBzaElYGJUrzwodck3Lx6IE2lA0rFREo" href="https://lib.baomitu.com/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  <link href="../../css/page.css" rel="stylesheet">
  <script crossorigin="anonymous" integrity="sha384-pPttEvTHTuUJ9L2kCoMnNqCRcaMPMVMsWVO+RLaaaYDmfSP5//dP6eKRusbPcqhZ" src="https://lib.baomitu.com/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <script crossorigin="anonymous" integrity="sha384-8t+aLluUVnn5SPPG/NbeZCH6TWIvaXIm/gDbutRvtEeElzxxWaZN+G/ZIEdI/f+y" src="https://lib.baomitu.com/vue/2.6.10/vue.min.js"></script>
  <script src="../../js/page.js"></script>
  <script src="../../js/changeTitle.js"></script>
  <link href="../../imgs/favicon.ico" rel="shortcut icon">
  <script src="../../js/goToHome.js"></script>
  <title></title>
  <script>
    var data={
      title:'浮动模块，如何保持保持高度一致？',
      content:{
        intro:{
          list:[
            {
              title:'使用说明：',
              className:'bs-callout-info',
              list:[
                {title:'基础配置：',content:'jq'}
                ,{title:'需要的代码：',content:'核心js代码，核心html部分代码和style代码只为演示方便'}
                ,{title:'如何使用：',content:'直接复制最下面的js源码'}
                ,{title:'API：',content:'setSameHeight(cols,item)第一个参数是列数，第二个参数是列表每一项的名称'}
              ]
            }
            ,{
              title:'实现原理：',
              className:'bs-callout-warning',
              list:[
                {
                  title:'',
                  content:'找到同行内最高的高度，作为所有的高度'
                }
              ]
            }
            ,{
              title:'问题描述：',
              className:'bs-callout-warning',
              list:[
                {
                  title:'为何存在：',
                  content:'有时候在做多个模块浮动布局时，由于某个模块比其他的高，会使后面紧挨着他的模块被“卡住”，导致页面错乱'
                }
              ]
            }
          ]
        }
      }
    };
  </script>
  <style>
    .fb{
      font-weight: bold;
    }
    #detail1{
      margin-right: 0;
    }
    #detail1,#detail2{
    }
    .detailModal__item{
      border:1px solid #00a0e9;
    }
    #detail1 .detailModal__item:nth-child(4n+3),#detail1 .detailModal__item:nth-child(4n+4){
      background-color: lightgreen;
    }
    #detail2 .detailModal__item:nth-child(6n+4),#detail2 .detailModal__item:nth-child(6n+5),#detail2 .detailModal__item:nth-child(6n+6){
      background-color: lightgreen;
    }
  </style>
</head>
<body>
<div id="page">
  <div class="container">
    <h3 class="text-center">{{title}}</h3>
    <div class="bs-callout" :class="item.className" v-for="item in content.intro.list">
      <h4>{{item.title}}</h4>
      <ul>
        <li v-for="item2 in item.list"><b>{{item2.title}}</b>{{item2.content}}</li>
      </ul>
    </div>
  </div>
  <script>
    var page = new Vue({
      el: '#page',
      data: data
    });
  </script>
</div>

<div class="container">
  <section class="panel panel-info">
    <div class="panel-heading">浮动模块，如何保持保持高度一致？</div>
    <div class="panel-body">
      <!--核心html代码 s-->
      <div class="row">
        <div class="col-sm-6">
          <div class="row ml0 mr0" id="detail1">
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  公司名称：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  昊商易通电子商务（北京）有限公司
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  电话：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  86-10-62159200
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  姓名：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  展商名录
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  地址：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  北京朝阳区八里庄西里61号远洋商务150
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  传真：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  86-10-62159200
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  手机：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  182****3611
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  邮箱：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  715560471@qq.com
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  网址：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  www.highset.cn
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  职务：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  工程师
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  公司性质：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  外资独资 这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  展品类别：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  金属切削机床 这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-6 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  届数:
                </div>
                <div class="col-xs-8">
                  15
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col-sm-6">
          <div class="row ml0 mr0" id="detail2">
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  公司名称：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  昊商易通电子商务（北京）有限公司
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  电话：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  86-10-62159200
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  姓名：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  展商名录
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  地址：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  北京朝阳区八里庄西里61号远洋商务150
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  传真：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  86-10-62159200
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  手机：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  182****3611
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  邮箱：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  715560471@qq.com
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  网址：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  www.highset.cn
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  职务：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  工程师
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  公司性质：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  外资独资 这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  展品类别：
                </div>
                <div class="col-xs-8 sliceStr" data-len-pc="18" data-len-wap="18" data-type="wap">
                  金属切削机床 这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。这里是文章测试标题，含标点一共二十个字。
                </div>
              </div>
            </div>
            <div class="col-xs-12 col-sm-4 detailModal__item">
              <div class="row">
                <div class="col-xs-4 fb">
                  届数:
                </div>
                <div class="col-xs-8">
                  15
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--核心html代码 e-->
    </div>
  </section>
</div>
<!--核心js-->
<script>
  $(function () {
    function setSameHeight(cols,item){
      var arrH1=[],arrH2=[];
      $(item).each(function(index,item){
        arrH1.push($(item).height());
      });
      for(var i= 0,len=arrH1.length;i<len;i+=cols){
        for(var j= 0;j<cols;j++){
          arrH2.push(Math.max(arrH1[i],arrH1[i+1]));
        }
      }
      $(item).each(function(index,item){
        $(item).height(arrH2[index]);
      });
    }
    setSameHeight(2,'#detail1 .detailModal__item'); // 一行内不同列的高度一致
    setSameHeight(3,'#detail2 .detailModal__item'); // 一行内不同列的高度一致
  });
</script>
<!--核心js-->
<div class="container">
  <section class="panel panel-info">
    <div class="panel-heading">源码</div>
    <div class="panel-body">
      <!--核心代码 s-->
      <div class="row">
        <div class="col-sm-12">
          <div class="">
            <p>
<pre>
  $(function () {
    function setSameHeight(cols,item){
      var arrH1=[],arrH2=[];
      $(item).each(function(index,item){
        arrH1.push($(item).height());
      });
      for(var i= 0,len=arrH1.length;i&lt;len;i+=cols){
        for(var j= 0;j&lt;cols;j++){
          arrH2.push(Math.max(arrH1[i],arrH1[i+1]));
        }
      }
      $(item).each(function(index,item){
        $(item).height(arrH2[index]);
      });
    }
    setSameHeight(2,'#detail1 .detailModal__item'); // 一行内不同列的高度一致
    setSameHeight(3,'#detail2 .detailModal__item'); // 一行内不同列的高度一致
  });
</pre>
            </p>
          </div>

        </div>
      </div>
      <!--核心代码 e-->
    </div>
  </section>
</div>
</body>

</html>
